<?php

namespace app\common;


use think\cache\driver\Redis;
use think\facade\Cache;
use think\facade\Log;

class MyRedis
{
    public function set($key, $value, $expire_time = 0)
    {
        //echo '给';exit();

        $result = Cache::store('redis')->set($key,$value);
//        $result = parent::set($key, $value);
//        if ($expire_time) {
//            parent::expire($key, $expire_time);
//        }
        //echo $result.'给';exit();
        Log::record(date('Y-m-d H:i:s').'Redis SET : ' . ($result ? '成功' : '失败') . ' Key: ' . $key, 'notice');
        return $result;
    }

    public function get($key)
    {
        $result = Cache::store('redis')->get($key);
        Log::record(date('Y-m-d H:i:s').'Redis GET : ' .  '成功' . ' Key: ' . $key, 'notice');
        return $result;
    }
}